< previous page page_100 next page >

Page 100
Puzzle 23
There Is a Question in There Somewhere
Where do these puzzles come from?
One of my goals for this book was to develop puzzles that are real. What do I mean by this? I've sometimes found that sample code in books is somewhat artificial. For example, object-oriented programming is demonstrated by using animalsyou have a class named Animal with inherited classes that are specific types of animals, such as dog or cat. This is fine if you're running a zoo, but let's face it: Most programmers don't create software for zoos. They may work in offices that bear some resemblance to zoos, but I digress. My point is that book examples are sometimes just a bit irrelevant.
With this book, I'm fairly confident I've avoided that trap. How can I be so sure? Rather than explain, I thought I would demonstrate. Consider this, if you will, a puzzle on how to create these types of puzzles.
First, the inspiration for the puzzle.
The following is a real inquiry I received about two days ago:
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
Dan, you've been very helpful in the pastI'm hoping you can help with what I'm sure is actually a simple question.
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
I'm trying to use the user_info_2 structure with the NetAddUser function from VBA. Part of this structure is: PBYTE usri2_logon_hours; points to a 21-byte (168 bits) bit string that specifies . . .
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
How do I include this in my type declaration? Also, there is a constant in the C header as:
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
#define USER_MAXSTORAGE_UNLIMITED ((unsigned long)-1L)
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
Isn't this a contradiction?
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
Should I just declare this as a long constant with the value of 1? Thanks in advance!
Now, I don't want to give you the impression that I answer all of the questions I receive. Time does not permit me to answer more than a few. In this case, however, the question struck me as perfect for this book. I gave my correspondent a

 
< previous page page_100 next page >